//
//  ImageTableViewCell.m
//  网易新闻段子
//
//  Created by 洛洛大人 on 16/6/22.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ImageTableViewCell.h"
#import "ImageModel.h"
#import "GetHeightTools.h"
#import "UIImageView+WebCache.h"
@interface ImageTableViewCell()
@property(nonatomic, retain)UIImageView *imgOfimage;
@end

@implementation ImageTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        self.imgOfimage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imgOfimage];
        [self.imgOfimage release];
        
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    CGFloat imgHeight = [GetHeightTools imageHeightWith:self.modelOfImage.img];
    self.imgOfimage.frame = CGRectMake(10, 20 + imgHeight, CGRectGetWidth(self.contentView.bounds)  - 20, imgHeight);
    
    
}



-(void)setModelOfImage:(ImageModel *)modelOfImage{
    if(_modelOfImage != modelOfImage){
        [_modelOfImage release];
        _modelOfImage = [modelOfImage retain];
        
    }
//    NSURL *url = [NSURL URLWithString:modelOfImage.imgImage];
//    [_imgOfimage sd_setImageWithURL:url];
    
    self.imgOfimage.image = [UIImage imageNamed:modelOfImage.img];
}







@end
